﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="QuanLySanPham.aspx.cs" Inherits="Admin_QuanLySanPham" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <h3>
        Danh sách sản phẩm</h3>
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="IDTaiLieu" DataSourceID="SqlDataSource1" OnSelectedIndexChanging="ListView1_SelectedIndexChanging" OnItemDeleted="Deleted"
        EnableModelValidation="True">
        <EditItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                </td>
                <td>
                    <asp:Label ID="IDTaiLieuLabel1" runat="server" Text='<%# Eval("IDTaiLieu") %>' />
                </td>
                <td>
                    <asp:TextBox ID="IDLoaiTLTextBox" runat="server" Text='<%# Bind("IDLoaiTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TenTLTextBox" runat="server" Text='<%# Bind("TenTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="HinhAnhTextBox" runat="server" Text='<%# Bind("HinhAnh") %>' />
                </td>
            </tr>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table id="Table1" runat="server" style="">
                <tr>
                    <td>
                        No data was returned.
                    </td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <tr style="">
                <td>
                    &nbsp;
                </td>
                <td>
                    <asp:TextBox ID="IDLoaiTLTextBox" runat="server" Text='<%# Bind("IDLoaiTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TenTLTextBox" runat="server" Text='<%# Bind("TenTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="HinhAnhTextBox" runat="server" Text='<%# Bind("HinhAnh") %>' />
                </td>
                <td>
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                </td>
            </tr>
        </InsertItemTemplate>
        <ItemTemplate>
            <tr style="">
                <td>
                    <asp:Label ID="IDTaiLieuLabel" runat="server" Text='<%# Eval("IDTaiLieu") %>' />
                </td>
                <td>
                    <asp:Label ID="TenTLLabel" runat="server" Text='<%# Eval("TenTL") %>' />
                </td>
                <td>
                    <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTLCha") %>' />
                </td>
                <td>
                  
                    <img src="../Image/Sach/<%# Eval("HinhAnh") %>" width="100px" />
                </td>
                <td>
                    <asp:ImageButton ID="Button3" runat="server" CommandName="Select" ImageUrl="images/edit.png"
                        Text="Edit" />
                    <asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" ImageUrl="images/drop.png" />
                </td>
            </tr>
        </ItemTemplate>
        <LayoutTemplate>
            <table id="Table2" runat="server">
                <tr id="Tr1" runat="server">
                    <td id="Td1" runat="server">
                        <table id="itemPlaceholderContainer" runat="server" border="0" style="" class="table_ds_loai_tl">
                            <tr id="Tr2" runat="server" style="">
                                <th id="Th1" runat="server">
                                    Mã
                                </th>
                              
                                <th id="Th2" runat="server">
                                    Tên
                                </th>

                                  <th id="Th3" runat="server">
                                    Thuộc loại
                                </th>

                                <th id="Th4" runat="server">
                                    Hình ảnh
                                </th>
                                <th id="Th5" runat="server">
                                    Công cụ
                                </th>
                            </tr>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr id="Tr3" runat="server">
                    <td id="Td2" runat="server" style="">
                        <asp:DataPager ID="DataPager1" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False"
                                    ShowPreviousPageButton="False" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"
                                    ShowPreviousPageButton="False" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
                </td>
                <td>
                    <asp:Label ID="IDTaiLieuLabel" runat="server" Text='<%# Eval("IDTaiLieu") %>' />
                </td>
                <td>
                    <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
                </td>
                <td>
                    <asp:Label ID="TenTLLabel" runat="server" Text='<%# Eval("TenTL") %>' />
                </td>
                <td>
                    <asp:Label ID="HinhAnhLabel" runat="server" Text='<%# Eval("HinhAnh") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="OverwriteChanges"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [TaiLieu] WHERE [IDTaiLieu] = @original_IDTaiLieu"
        InsertCommand="INSERT INTO [TaiLieu] ([IDLoaiTL], [TenTL], [HinhAnh]) VALUES (@IDLoaiTL, @TenTL, @HinhAnh)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [IDTaiLieu], [IDLoaiTL], [TenTL], [HinhAnh], (SELECT b2.[TenLoaiTL] FROM [LoaiTaiLieu] b2 WHERE b2.[IDLoaiTL] = b1.[IDLoaiTL]) as IDLoaiTLCha FROM [TaiLieu] b1"
        UpdateCommand="UPDATE [TaiLieu] SET [IDLoaiTL] = @IDLoaiTL, [TenTL] = @TenTL, [HinhAnh] = @HinhAnh WHERE [IDTaiLieu] = @original_IDTaiLieu AND (([IDLoaiTL] = @original_IDLoaiTL) OR ([IDLoaiTL] IS NULL AND @original_IDLoaiTL IS NULL)) AND (([TenTL] = @original_TenTL) OR ([TenTL] IS NULL AND @original_TenTL IS NULL)) AND (([HinhAnh] = @original_HinhAnh) OR ([HinhAnh] IS NULL AND @original_HinhAnh IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_IDTaiLieu" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenTL" Type="String" />
            <asp:Parameter Name="original_HinhAnh" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="TenTL" Type="String" />
            <asp:Parameter Name="HinhAnh" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="TenTL" Type="String" />
            <asp:Parameter Name="HinhAnh" Type="String" />
            <asp:Parameter Name="original_IDTaiLieu" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenTL" Type="String" />
            <asp:Parameter Name="original_HinhAnh" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>

